package charts ;
import charts.series.Element;
import charts.series.bars.Sketch;
import charts.BarBase.BARBASESTRUCT;
import string.Utils;
import ColorConverter.Color;

typedef BARSKETCHSTRUCT = {> BARBASESTRUCT,
	var outline_color	: Color;
	var offset		: Int;
}

class BarSketch extends BarBase {
	var outline_color: Color;
	var offset: Int;
	
	public function new ( json: Dynamic, group: Float ) {
		
		//
		// these are specific values to the Sketch
		// and so we need to sort them out here
		//
		var style : BARSKETCHSTRUCT = {
			outline_color	: Hex("#000000"),
			offset		: 6
		};
		
		ObjectHelper.merge_2( json, style );
		
		super( style, group );
	}

	//
	// called from the base object
	//
	override function get_element( index: Int, value: Dynamic ): Element {
		
		var default_style : BARSKETCHSTRUCT = this.get_element_helper( value );
		
		// our parent color is a number, but
		// we may have our own color:
		//if(Std.is(default_style.color,String ))
		//	default_style.color = Utils.get_color( default_style.color );
			
		//if ( !default_style['outline-color'] )
		//	default_style['outline-color'] = this.style['outline-color'];
		
		//if(Std.is(default_style['outline-color'],String ))
		//	default_style['outline-color'] = 
		//		Utils.get_color( default_style['outline-color'] );		

		if ( !Reflect.hasField(default_style, 'outline_color'))
			default_style.outline_color = Hex(this.style.outline_color);
		
		if ( !Reflect.hasField(default_style, 'offset') )
			default_style.offset = this.style.offset;

		return new Sketch( index, default_style, this.group );
	}
}
